package com.mebs.edi.parser.dom;

import java.sql.Time;
import java.text.SimpleDateFormat;
import java.util.Date;

public class DomAttributeConverter {
	
	private static final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
	private static final SimpleDateFormat timeFormat = new SimpleDateFormat("HH:mm:ss");
	

	public static String convertToDomAttribute(Object attributeValue) {
		if (attributeValue == null) {
			return null;
		} else if (attributeValue instanceof Time) {
			Time time = (Time)attributeValue;
			return timeFormat.format(time);	
		} else if (attributeValue instanceof Date) {
			Date date = (Date)attributeValue;
			return dateFormat.format(date);	
		} else {
			return attributeValue.toString();
		}
	}

}
